const dbCloud = require('../dbCloud.js');

const { db_credit } = dbCloud;

/**
 * 获取信用卡列表
 */
const getCreditList = async (openid) => {
  return db_credit.where({
    _openid:openid
  }).get();
};

/**
 * 添加信用卡
 */
const addCredit = async (data) => {
  return db_credit.add({
    data
  });
}

/**
 * 获取信用卡信息
 */
const getCreditInfo = async (id) => {
  return db_credit.doc(id).get();
}

/**
 * 删除信用卡
 */
const delCredit = async (id) => {
  return db_credit.doc(id).remove();
}

module.exports = {
  getCreditList,
  getCreditInfo,
  addCredit,
  delCredit
};
